from django.urls import path, re_path, include
from django.views.static import serve
from django.conf import settings
from . import views
from lucky.views import page_not_found, permission_denied, page_error
from django.contrib import admin
from django.views.generic.base import RedirectView, TemplateView

handler403 = permission_denied
handler404 = page_not_found
handler500 = page_error
# 子路由
urlpatterns = [
    # 解决关闭Debug找不到css/js文件问题
    re_path(r'^static/(?P<path>.*)', serve, {'document_root': settings.STATIC_ROOT}),

    # 登录页,注册页面
    path('', views.toLoginView),

    #退出登录
    path('logout/', include([
        path('',views.logoutView),
        path('signup/', views.toSignView),
        path('changePwd/', views.toChangePwdView),
    ])),

    path('wxLogin/', views.wxLoginView),

    # 登录相关路径
    path('login/', include([
        path('', views.toLoginView),
        path('signup/', views.toSignView),
        path('changePwd/', views.toChangePwdView),
        path('changePwd/changePd', views.changePd, name='changePd'),
        path('changePwd/checkUsername', views.checkUsername, name='checkUsername'),
        path('changePwd/sendMes', views.sendMes, name='sendMes'),
    ])),

    # 注册相关路径
    path('signup/', include([
        path('', views.toSignView),
        path('signUp', views.signUp, name='signUp'),
        path('sendMes', views.sendMes, name='sendMes'),
    ])),

    # 修改密码相关路径
    path('changePwd/', include([
        path('', views.toChangePwdView),
        path('changePd', views.changePd, name='changePd'),
        path('checkUsername', views.checkUsername, name='checkUsername'),
        path('sendMes', views.sendMes, name='sendMes'),
    ])),

    # 主页
    path('index/', views.loginView),
    path('index/home.html', views.hello),
    path('index/device.html', views.device),
    path('index/aichart.html', views.aiChart),
    path('index/aiLinkView', views.aiLinkView, name='aiLinkView'),
    path('WW_verify_rffcwWXq422FfrM2.txt',
         TemplateView.as_view(template_name='WW_verify_rffcwWXq422FfrM2.txt', content_type='text/plain')),
    path('WW_verify_DLNd1Hvem7wOSP87.txt',
         TemplateView.as_view(template_name='WW_verify_DLNd1Hvem7wOSP87.txt', content_type='text/plain')),

    # 书籍相关路径
    path('index/ebook.html', views.ebook),
    path('index/getAllBook', views.getAllBook, name='getAllBook'),
    path('index/updateAllBook', views.updateAllBook, name='updateAllBook'),
    path('index/get_progress', views.get_progress, name='get_progress'),

    path('loginAPP', views.loginAPP,name='loginAPP'),#APP登录
    path('getVideoPcMac', views.getVideoPcMac, name='getVideoPcMac'),
    path('addVideoPcMac', views.addVideoPcMac, name='addVideoPcMac'),

    #支付
    path('index/pays.html', views.pays, name='pays'),
    path('pay_post', views.pay_post, name='pay_post'),
    path('alipay_notify', views.alipay_notify, name='alipay_notify'),
    # path('pay_result/', views.pay_result, name='pay_result'), # 支付宝处理完成后回调的get请求路由
    # path('update_order/', views.update_order, name='update_order'),# 支付宝处理完成后回调的post请求路由



    # path('index/admin', admin.site.urls),
]

